home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / DoTasks.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  31.6 KB  |  761 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    DoTasks.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    KTA, KL, ML, GS et al
  9. #
  10. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    .0.1111>     2/13/96    ML        DoText - add hooks before and after calls         to TypeStr
  19. #                                    (international support)
  20. #    .0.1111>     2/13/96    ML        DoText - pass context into global hooks, add hooks before and
  21. #                                    after calls to TypeStr (international support)
  22. #    0.1110+>     2/13/96    ML        DoText - add hooks before and after calls to TypeStr
  23. #                                    (international support)
  24. #    .0.1110>    11/21/95    ML        DoCloseApp - change header to reflect revision to Quit() task.
  25. #    .0.119+>    11/20/95    ML        DoCloseApp - change header to reflect revision to Quit() task.
  26. #    1.0.119>    11/15/95    ML        DoSetUpApp and DoCloseApp - add gScriptBeginCritical         and
  27. #                                    gScriptEndCriticalHooks for threading         support
  28. #    .0.118+>    11/15/95    ML        DoSetUpApp and DoCloseApp - add gScriptBeginCritical and
  29. #                                    gScriptEndCriticalHooks for threading support
  30. #    1.0.118>    11/10/95    ML        DoDraw - Call RandomDrawObject once for randow draw object
  31. #    .0.117+>    11/10/95    ML        DoDraw
  32. #    1.0.117>     11/8/95    ML        DoWindow - added global hook for tail patch
  33. #    .0.116+>     11/8/95    ML        DoWindow - added global hook for tail patch
  34. #    1.0.116>      3/8/95    ML        DoSetUpApp() - remove gSetUpScrapText, gSetUpScrapPict
  35. #    .0.115+>      3/8/95    ML        DoSetUpApp() - remove gSetUpScrapText, gSetUpScrapPict
  36. #    1.0.115>     2/14/95    KTA        DoSetupApp() - Added BooleanFlag to FindWindow() call
  37. #    1.0.114>     1/10/95    KTA        DoWindow() - WindowFunction() now checks gDoWindowList and
  38. #                                    removes undesired tests.
  39. #    1.0.113>      1/6/95    KTA        DoSetUpAp() - removed some unneeded code..
  40. #    1.0.112>     12/7/94    ML        Added Exception Handling support
  41. #    .0.111+>     12/7/94    ML        Added Exception Handling support
  42. #    1.0.111>     7/18/94    KTA        DoSetUpApp() - Added support for pNewDocPath to handle
  43. #                                    hierarchical menuitems.
  44. #    1.0.110>     5/10/94    ML        Moved call to ProfileApplication from LaunchTwitch() to
  45. #                                    DoSetUpApp()
  46. #    1.0.19+>     5/10/94    ML        Moved call to ProfileApplication for LaunchTwitch() to
  47. #                                    DoSetUpApp()
  48. #    <1.0.19>     4/26/94    KTA        DoFiles() - Only call Revert() if ModifyDocument >= 1.
  49. #    <1.0.18>     12/6/93    KTA        Fixed problem with spaces in DoText()
  50. #    <1.0.17>     12/6/93    KTA        Marked DoCloseApp().
  51. #    <1.0.16>     12/2/93    KTA        DOSetupApp() - Changed output when aboutBox not tested, and
  52. #                                    aligned the header, added gDoSetupAppHook1 and 2 and added
  53. #                                    gDoCloseAppHook1 and 2. Removed all calls to DoSpecialTest().
  54. #    <1.0.15>    11/19/93    NAGA        modify TCS Format
  55. #    <1.0.14>     9/29/93    KTA        DoWindow() - Changed one output line to read, 'Scrolling will
  56. #                                    not be tested in DoWindow().'
  57. #    <1.0.13>     9/22/93    KTA        DoSetUpApp() - Bug Fix gSetUpForSaveDoc was accidentally renamed
  58. #                                    gSetUpForSaveDoc.
  59. #    <1.0.12>     9/13/93    KTA        Updated TestLevel specification.
  60. #    <1.0.11>      9/9/93    KTA        DoSetUpApp() - Changed output line so it does not say 'About to
  61. #                                    …'
  62. #    <1.0.10>     8/30/93    KTA        Updated task headers and parameters.
  63. #     <1.0.9>     8/25/93    KTA        Added support for parity checking the TCS stack.
  64. #     <1.0.8>     7/30/93    KTA        DoFiles() - only call revert if ModifyDocument was successful.
  65. #     <1.0.7>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  66. #     <1.0.6>     7/14/93    KTA        International Support: see DoFiles(), DoSetupApp(), and
  67. #                                    DoCloseApp().
  68. #        <1+>     5/21/93    NAGA    Adding header and porting old files to follow new standards
  69. #
  70. # ****************************************************************************
  71. #
  72.  
  73. ########################################################################
  74. #                            External libraries 
  75. #=======================================================================
  76. Libraries "OutPut.Lib","Font.Lib","StandardFile.Lib","TCS.Lib","Draw.Lib",
  77. "Print.Lib","LaunchQuit.Lib","Misc.Lib","TargetCheck.Lib", "DA.Lib",
  78. "UserInterface.Lib", "ExceptionHandling.Lib";
  79.  
  80.  
  81. #########################################################################
  82. #                        DoDraw( pTestMethod, pSpecifier, pNumTimes )
  83. #========================================================================
  84. # Author:        KTA
  85. # Description:    This task is a high level task which controls the amount and
  86. #                type of draw testing which will be automatically performed (based upon
  87. #                predefined application specific data structures).  
  88. # Parameters:    pTestMethod - the method of testing desired.
  89. #                            1 - random object will be generated <pNumtimes> times.
  90. #                            2 - a random object will be generated for all tools
  91. #                                defined in the gToolList.
  92. #                pSpecifier - (String, integer, descriptor) window pSpecifier in
  93. #                            which drawing will occur.
  94. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  95. # Task references : A number of global undefined task references have been provided 
  96. #                    to allow scriptwriters the ability to customize calls to DoDraw();
  97. #                        gDoDrawHook1 - prior to any drawing.
  98. #                        gDoDrawHook2 - after drawing each individual object
  99. #                        gDoDrawHook3 - after completion of drawing all objects
  100. # Returns:        Nothing
  101. # Examples:        DoDraw(1,1,1)
  102. # Assumptions:    Data Structures are set up correctly (see the HitchHiker's guide for details)
  103. # Notes:        If the pTestMethod parameter is not explicitly passed in it
  104. #                can be set by defining the global gDrawLevel. gDrawLevel can
  105. #                be an integer or a list.  If gDrawLevel is an integer it will be
  106. #                used as the pTestMethod input parameter. If gDrawLevel is a list
  107. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  108. #========================================================================
  109. # History:
  110. # KTA    7/30/93     Changed name of gSetUpDoDraw -> gDoDrawHook1, changed name of 
  111. #                 gClearDoDraw -> gDoDrawHook3, Added gDoDrawHook2
  112. # KTA    8/25/93     Added ability to set gDrawLevel to a list
  113. # ML    11/10/95     Call RandomDrawObject once for randow draw object
  114. #########################################################################
  115. TASK DoDraw(pTestMethod := -1, pSpecifier := 0, pNumTimes := 1 )
  116. begin
  117.     global gDrawLevel, gToolList;
  118.     
  119.     if (global gDebugFlag)
  120.     begin
  121.         println "DoDraw() input paramters pTestMethod - {pTestMethod}, pSpecifier - {pSpecifier}, mu,Objects - {pNumTimes}";
  122.         println " gDrawLevel - ", gDrawLevel;
  123.         
  124.     end;
  125.     if (pTestMethod = -1)
  126.     begin
  127.         if (typeOf(gDrawLevel) = 'list')
  128.         begin
  129.             pTestMethod := gDrawLevel[1];
  130.             pNumTimes := gDrawLevel[2];
  131.         end;
  132.         else
  133.             pTestMethod := gDrawLevel;
  134.     end;
  135.     
  136.     if (pTestMethod)
  137.     begin
  138.         if (global gDoDrawHook1)
  139.             call (gDoDrawHook1);
  140.         theObject := RandomDrawObject();
  141.         if (pTestMethod = 1)                # Totally Random Object
  142.         begin
  143.             Println "------- DoDraw - pTestMethod (1) ('{pNumTimes}' -  Random structure(s)) --------";
  144.             for i := 1  to pNumTimes
  145.             begin
  146.                 println "DoDraw - ",theObject;
  147.                 DrawObject(theObject, pSpecifier);
  148.                 If(global gDoDrawHook2)
  149.                     call(gDoDrawHook2);
  150.             end;
  151.         end;
  152.         else if (pTestMethod = 2)                # Random structure for all tools
  153.         begin
  154.             Println "------- DoDraw - pTestMethod (2) (Random structure for all tools) {pNumTimes} Times--------";
  155.             for i := 1 to pNumTimes
  156.             begin
  157.                 for toolNum := 1 to card(gToolList) 
  158.                 begin 
  159.                     theTool := gToolList[toolNum];
  160.                     # Insert the tool description into the object structure 
  161.                     # so the object knows how to draw itself
  162.                     theObject := InsertElemStruct(theTool, theObject);
  163.                     println "DoDraw - ",theObject;
  164.                     DrawObject(theObject, pSpecifier);
  165.                     If(global gDoDrawHook2)
  166.                         call(gDoDrawHook2);
  167.                 end;
  168.             end;
  169.         end; 
  170.     end;
  171.     else
  172.         Println "-------- DoDraw is turned - OFF ---------------";
  173.  
  174.         Println "-----------------------------------------------";
  175.         Println;
  176.     if global gDoDrawHook3
  177.         call (gDoDrawHook3);
  178. end; # DoDraw()
  179.  
  180. #########################################################################
  181. #        DoWindow( pTestMethod, pSpecifier, pRestoreWindow, pNumTimes )
  182. #========================================================================
  183. # Author:        KTA
  184. # Description:    This task is a high level task which controls the amount and
  185. #                type of window testing which will be automatically performed.  
  186. # Parameters:    pTestMethod - the method of testing desired.
  187. #                            1 - a less complete window test (functionlist build 
  188. #                                dynamically based on gDoWindowList see below)
  189. #                            2 - complete window test scrolling, sizing, dragging, zooming.
  190. #                pSpecifier - (String, integer, descriptor) window pSpecifier for 
  191. #                            to be exercised.
  192. #                pRestoreWindow - Boolean - indicates whether or not to restore 
  193. #                                the window to it's original condition.
  194. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  195. # Returns:        Nothing
  196. # Examples:        DoWindow(1,0,0,2)
  197. # Assumptions:    
  198. # Notes:        For more info in what each test does see TestWindow() in 
  199. #                'UserInterface.lib'. 
  200. #                If the pTestMethod parameter is not explicitly passed in it
  201. #                can be set by defining the global gWindowLevel. gWindowLevel can
  202. #                be an integer or a list.  If gWindowLevel is an integer it will be
  203. #                used as the pTestMethod input parameter. If gWindowLevel is a list
  204. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  205. #
  206. #                A global, gDoWindowList, has been provided as a way to indicate
  207. #                which tests are available for a given application.
  208. #                NOTE: This is only valid if pTestWindow evaluates to 2.
  209. #                e.g. global gDoWindowList := {1,1,1,1};
  210. #                 Set each element to 1 or 0.  
  211. #                Flag for performing DoWindows tests as follows:
  212. #                 Element: 1 - Sizing
  213. #                         2 - Scrolling
  214. #                         3 - Dragging
  215. #                         4 - Zooming
  216. #
  217. #========================================================================
  218. # History:
  219. # KTA    9/29/93 Changed output to read "Scrolling will not be tested in DoWindow()."
  220. # KTA    1/10/95 WindowFunction() now checks gDoWindowList and removes undesired tests.
  221. # ML    11/08/95 added global gDoWindowTailPatch
  222. #########################################################################
  223. TASK DoWindow(pTestMethod := -1, pSpecifier := 0, pRestoreWindow := 0, pNumTimes := 1 )
  224. begin
  225.     global gWindowLevel;
  226.     if (pTestMethod = -1)
  227.     begin
  228.         if (typeOf(gWindowLevel) = 'list')
  229.         begin
  230.             pTestMethod := gWindowLevel[1];
  231.             pNumTimes := gWindowLevel[2];
  232.         end;
  233.         else
  234.             pTestMethod := gWindowLevel;
  235.     end;
  236.     
  237.     if (pTestMethod)
  238.     begin        
  239.         if global gSetupDoWindow
  240.             call (gSetupDoWindow);
  241.  
  242.         if (pTestMethod = 1)                                                 ## Quicklook Window Tests
  243.         begin
  244.             Println "------- DoWindow - pTestMethod (1) - (Quicklook Window Test)  {pNumTimes} times --------";
  245.             Println "---------- global gDoWindowList :=  {global gDoWindowList} --------";
  246.             WindowFunctionList := {2,1,3,7,13,14,15,17,17,11}; # initialize list
  247.             TestWindow(pSpecifier,WindowFunctionList,pRestoreWindow,pNumTimes);
  248.         end;     
  249.         else if (pTestMethod = 2)                                            ## Complete Window Test
  250.         begin     
  251.             Println "------- DoWindow - pTestMethod (2) - (Complete Window Test) {pNumTimes} times--------";
  252.             Println "---------- global gDoWindowList :=  {global gDoWindowList} --------";
  253.             TestWindow(pSpecifier,0, pRestoreWindow,pNumTimes);                #        Performs functions 1 through 17
  254.         end;
  255.         else if(TypeOf(pTestMethod) = 'list')                ## Pass in your own Window test (see WindowTest() in the Window.Lib
  256.         begin
  257.             Println "------- DoWindow - pTestMethod 'list' - (Pass in your own) --------";
  258.             Println "---------- global gDoWindowList :=  {global gDoWindowList} --------";
  259.             TestWindow(pSpecifier, pTestMethod, pRestoreWindow, pNumTimes);    
  260.         end;
  261.     end;
  262.     else
  263.         Println "-------- DoWindow is turned - OFF ---------------";
  264.  
  265.     Println "-----------------------------------------------";
  266.     Println;
  267.     if (global gDoWindowTailPatch)
  268.         call (global gDoWindowTailPatch, pTestMethod, pSpecifier, pRestoreWindow, pNumTimes);
  269. end; # DoWindow()
  270.  
  271.  
  272. #########################################################################
  273. #                        DoText(pTestMethod, pNumTimes)
  274. #========================================================================
  275. # Author:        KTA
  276. # Description:    This task is a high level task which controls the amount and
  277. #                type of font testing which will be automatically performed.  
  278. # Parameters:    pTestMethod - the method of testing desired.
  279. #                            1 - Random font test
  280. #                            2 - QuickLook font test
  281. #                            3 - WaterFall font test
  282. #                pNumTimes - (integer) number of times to perform the <pTestMethod>.
  283. #                            (not valid for WaterFall testing)
  284. # Returns:        nada
  285. # Examples:        DoText(2,3);
  286. # Assumptions:    global gFontList, gFontSizeList, gFontStyleList must be defined.
  287. # Notes:         If the pTestMethod parameter is not explicitly passed in it
  288. #                can be set by defining the global gFontLevel. gFontLevel can
  289. #                be an integer or a list.  If gFontLevel is an integer it will be
  290. #                used as the pTestMethod input parameter. If gFontLevel is a list
  291. #                the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
  292. #========================================================================
  293. # History:
  294. # KTA    1/18/94    Fixed problem that spaces were causing in intl systems.
  295. # ML    2/13/96 pass context into global hooks, add hooks before and after calls to
  296. #                TypeStr (international support).
  297. #########################################################################
  298. TASK DoText(pTestMethod := -1, pNumTimes := 1)
  299. begin
  300.     returnVal := 0;
  301.     
  302.     if not(global gSetFont)        #Auto Initilize if not done
  303.         InitFonts();
  304.     global kQLFontTest,gFontLevel,gFontList, gFontSizeList, 
  305.     gFontStyleList,gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu,gtextStr,gFontObject;
  306.     if (pTestMethod = -1)
  307.     begin
  308.         if (typeOf(gFontLevel) = 'list')
  309.         begin
  310.             pTestMethod := gFontLevel[1];
  311.             pNumTimes := gFontLevel[2];
  312.         end;
  313.         else
  314.             pTestMethod := gFontLevel;        # Set pTestMethod to global gFontLevel
  315.     end;
  316.     Println "The gFontList := ", gFontList;
  317.     Println "The gFontSizeList := ", gFontSizeList;
  318.     Println "The gFontStyleList := ", gFontStyleList;
  319.  
  320.     if (pTestMethod)
  321.     begin
  322.         if global gSetupDoText
  323.             call (gSetupDoText, pTestMethod, pNumTimes);
  324.         if (pTestMethod = 1)                        # Random font testing
  325.         begin
  326.             Println "------- DoText - pTestMethod (1) ∂({pNumTimes}∂) random (with global gFontLists) --------";
  327.             for numRecords := 1 to pNumTimes    # Type random font records <gNumRandom> times
  328.             begin
  329.                 gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  330.                 RandomRecord := RandomFontRecords();
  331.                 FontRecord := SetFontParams(RandomRecord,,gFontObject);
  332.                 if(FontRecord)
  333.                 begin
  334.                     if global gDoTextTypeStrHook1
  335.                         call (gDoTextTypeStrHook1, pTestMethod, pNumTimes);
  336.                     TypeStr("{gtextStr}");
  337.                     if global gDoTextTypeStrHook2
  338.                         call (gDoTextTypeStrHook2, pTestMethod, pNumTimes);
  339.                     ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  340.                     Println "• - ",FontRecord;
  341.                     returnVal := FontRecord;
  342.                 end;
  343.                 else
  344.                     Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
  345.             end;
  346.         end;
  347.         else if (pTestMethod = 2)                # Quicklook font testing
  348.         begin                                    # 1 random record for each font
  349.             Println "------- DoText - pTestMethod (2) - 1 record for each font in global gFontLists {pNumTimes} times--------";
  350.             for i := 1 to pNumTimes
  351.             begin
  352.                 for each FontItem in gFontList
  353.                 begin
  354.                     gFontObject := gFontObject + 1;  # Increment the object number for TCS info
  355.                     RandomRecord := RandomFontRecords({FontItem,"",""});
  356.                     FontRecord := SetFontParams(RandomRecord,,gFontObject);
  357.                     if(FontRecord)
  358.                     begin
  359.                         if global gDoTextTypeStrHook1
  360.                             call (gDoTextTypeStrHook1, pTestMethod, pNumTimes);
  361.                         TypeStr("{gtextStr}");
  362.                         if global gDoTextTypeStrHook2
  363.                             call (gDoTextTypeStrHook2, pTestMethod, pNumTimes);
  364.                         ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject);    # Match and report back what is actually selected
  365.                         Println "• - ",FontRecord;
  366.                         returnVal := FontRecord;
  367.                     end;
  368.                     else
  369.                         Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
  370.                 end;
  371.             end;    
  372.         end;
  373.         else if (pTestMethod = 3)                # WaterFall font testing
  374.         begin    
  375.             Println "------- DoText - pTestMethod (3) - WaterFall (with global gFontLists) --------";
  376.             WaterFallFontTest();
  377.             returnVal := 1;
  378.         end;
  379.     end;
  380.     Else
  381.         Println "-------- DoText is turned - OFF ---------------";
  382.     Println "-----------------------------------------------";
  383.     Println;
  384.     if global gClearDoText
  385.         call (gClearDoText, pTestMethod, pNumTimes);
  386.     Return(ReturnVal);
  387. end; # DoText()
  388.  
  389. #########################################################################
  390. #        DoFiles(pTestMethod, pFileName, pSaveAsFlag, pSelectOpen, pRevertMI )
  391. #========================================================================
  392. # Author:        KTA
  393. # Description:    This task is a high level task which controls the amount and
  394. #                type of file testing which will be automatically performed.
  395. # Parameters:    pTestMethod - Method of testing 
  396. #                            1 - All tests outlined below
  397. #                            2 - Save As/Replace, close, open.
  398. #                            3 - Save As/Cancel, Save, modify, revert.
  399. #                            4 - Save/Cancel,Save(unique), Save (same file name)/Replace,
  400. #                                Save (same file name)/create unique extension.
  401. #                            5 -    Save As/Cancel, Save
  402. #                pFileName - File name to use when saving file if none passed
  403. #                            a filename will be generated bassed on the 
  404. #                            applications name and the time.
  405. #                pSaveAsFlag - Valid for all Testmethods. Indicates whether 
  406. #                             selecting the Save As menuItem is necessary.
  407. #                                 1 - select Save As. HardCoded 'Save As'.
  408. #                                0 - Do not select SaveAs.
  409. #                                list - list containing ordinality of 'Save As' menuItem.
  410. #                            This parameter has been updated for international support.
  411. #                            Now it can also be a list which contains the ordinality of 
  412. #                            the Save As menuItem. If a it is a list then the Save As menuItem
  413. #                            will be selected using the contents of the list.
  414. #                            e.g. if pSaveAsFlag = {6,2}, the sixth menuitem from the 2nd menu will
  415. #                            be selected as the Save As menuItem.
  416. #                pSelectOpen - Only valid if <pTestMethod> evaluates to 2
  417. #                            0 - Don't select 'Open' or anything else
  418. #                            1 - Select 'Open' - hard coded
  419. #                            2 - Select 'Open' by way of keyboard equivelant 'o'.
  420. #                            list - list containing ordinality of 'Open' menuItem.
  421. #                pRevertMI - Only valid if <pTestMethod> evaluates to 3
  422. #                            '' - Hard coded 'Revert' menuItem will be selected
  423. #                            list - list containing ordinality of revert MenuItem
  424. # Returns:        nada
  425. # Examples:        DoFiles(2, "myFile", {6,2}, {4,2});            # Save, close, open.
  426. # Assumptions:    
  427. #========================================================================
  428. # History:
  429. # KTA 7/7/93     Added pSaveAsFlag to specify the SaveAs menuItem for SaveAs() - intl
  430. #                  Added pSelectOpen to specify the Open menuItem for OpenFile() - intl
  431. #                  Added pRevertMI to specify the Revert menuItem for Revert() - intl
  432. # KTA 7/30/93     Only call revert if ModifyDocument was successful
  433. # KTA 4/26/94     Only call revert if ModifyDocument >= 1
  434. # ML  5/10/94    Move Call to ProfileApplication to DoSetUpApp()
  435. #########################################################################
  436. TASK DoFiles(pTestMethod := -1,pFileName := "",pSaveAsFlag := 1, pSelectOpen := 2, pRevertMI := '')
  437. begin
  438.     global gLastSavedFile;
  439.  
  440.     if (pTestMethod)
  441.     begin
  442.         if (pTestMethod = 1)                    # All File tests
  443.         begin
  444.             Println "------- DoFiles - testMethod (1) - (All File tests) --------";
  445.             for i := 2 to 4
  446.                 DoFiles(i);
  447.         end;
  448.         else if (pTestMethod = 2)                # SaveFile, close it, open it.
  449.         begin
  450.             Println "------- DoFiles - testMethod (2) - (Save As/Replace, close it, open it) --------";
  451.             if (SaveAs(pFileName,1,pSaveAsFlag) = 1)    # if file saved, but no replace exist
  452.                 SaveAs(pFileName,1,pSaveAsFlag);            # Save as again, insures replace exist        
  453.             CloseWindow(,,0);                    
  454.             OpenFile(gLastSavedFile,pSelectOpen);
  455.         end;
  456.         else if (pTestMethod = 3)                # SaveFile, modify it, revert it.
  457.         begin
  458.             Println "------- DoFiles - testMethod (3) - (Save As/Cancel, Save file, modify it, revert it) --------";
  459.             CancelStandardFile(1,pSaveAsFlag);            # SaveAs/Cancel SelectButton('Cancel');
  460.             Save();
  461.             ModifyDocReturn := ModifyDocument();
  462.             if(ModifyDocReturn >= 1)
  463.                 Revert(pRevertMI);
  464.         end;
  465.         else if (pTestMethod = 4)                # Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique
  466.         begin
  467.             Println "------- DoFiles - testMethod (4) - (Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique) --------";
  468.             CancelStandardFile(,pSaveAsFlag);                    # SaveAs/Cancel keyEq('.');
  469.             SaveAs(,0, pSaveAsFlag);                        ## Save - uniqueName            
  470.             SaveAs(gLastSavedFile,1, pSaveAsFlag);            ## SaveSameName-OverWrite
  471.             SaveAs(gLastSavedFile,0, pSaveAsFlag);            ## SaveSameName-AddExtension for unique     
  472.         end;
  473.         else if (pTestMethod = 5)                # SaveFile, modify it, revert it.
  474.         begin
  475.             Println "------- DoFiles - testMethod (5) - (Save As/Cancel, Save file) --------";
  476.             CancelStandardFile(1,pSaveAsFlag);                # SaveAs/Cancel SelectButton('Cancel');
  477.             Save();
  478.         end;
  479.     end;
  480.     else
  481.         Println "-------- DoFiles is turned - OFF ---------------";
  482.     Println "-----------------------------------------------";
  483.     Println;
  484. end;
  485.  
  486. #########################################################################
  487. #     DoSetUpApp(pDismissOpeningDialog, pDefaultWindowSpec, pNewDocPath,
  488. #  pDismissNewDocDialog,pScrapText, pScrapPict, pSaveDoc, pOpenDoc)
  489. #=======================================================================
  490. # Author:              ML
  491. #
  492. # Description:        Sets up app after launch.  Matches app, closes default
  493. #                    window, creates a new document, optionally pastes from scrap, 
  494. #                    saves document.
  495. #
  496. # Parameters:        pDismissOpeningDialog - 0    No opening dialog
  497. #                                               1    type return key
  498. #                                        'string' select button named {string}        
  499. #                    pDefaultWindowSpec -    if -1, no default window - don't close         
  500. #                                            if 0, close first document window
  501. #                                            if string, then it holds title of window
  502. #                                            if integer > 0, then it holds ordinality of window
  503. #                                            Descriptor -  window descriptor
  504. #                    pNewDocPath -            0    don't create new doc
  505. #                                          {list} - containing ordinality of 'New' menuItem
  506. #                                            
  507. #                    pDismissNewDocDialog -     0    No new doc dialog
  508. #                                               1    type return key
  509. #                                        'string' select button named {string}
  510. #                    pScrapText -            0    Don't call Scrapbook(global ScrapText)
  511. #                                            1    call Scrapbook(global ScrapText)
  512. #                    pScrapPict -            0    Don't call Scrapbook(global ScrapPict)
  513. #                                            1    call Scrapbook(global ScrapPict)
  514. #                    pSaveDoc    -                0    Don't save newly created doc via DoFiles(2)
  515. #                                            1    Save newly created doc via DoFiles(2)
  516. #                                          {list} - containing ordinality of Save As menuItem
  517. #                    pOpenDoc    -            0    Don't save select 'Open' menuitem
  518. #                                            1    Select 'open' menuItem - hardcoded
  519. #                                            2    - keyEq('o');
  520. #                                          {list} - containing ordinality of 'Open' menuItem
  521. #                    
  522. # Task references : A number of global undefined task references have been provided 
  523. #                    to allow scriptwriters the ability to customize calls to DoSetUpApp();
  524. #                        gCustomScrapText - instead of generic Scrapbook(kScrapTEXT)
  525. #                        gCustomScrapPict - instead of generic Scrapbook(kScrapPICT)
  526. #                        gSetUpForSaveDoc - To do any setup before calling DoFiles(2)
  527. # Returns:            None
  528. #
  529. # Example:            DoSetUpApp(0,1,{'New','File'},0,0,0,1)
  530. #=======================================================================
  531. # History:    
  532. # KTA     7/7/93    Added pOpenDoc parameter to pass the Open menuItem to OpenFile if needed (intl)
  533. #                 Slightly modified pNewDocPath (intl)
  534. # KTA     7/19/93    changed specifier so descriptor is not embedded in a list.
  535. # KTA    8/24/93    TCS Stack parity check
  536. # KTA    9/9/93    Changed output line so it does not say 'About to …'
  537. # KTA    12/1/93 Deleted call to DoSpecialTest() and added hooks gDoSetUpAppHook1, 
  538. #                gDoSetUpAppHook2
  539. # KTA    7/18/94 Added support for pNewDocPath to handle hierarchical menuitems
  540. # ML    11/29/94    Added Exception Handling support
  541. # KTA    1/5/95    removed some unneeded code.
  542. # KTA    2/14/95    Added BooleanFlag to FindWindow() call
  543. # ML    3/8/95    removed gSetUpScrapText,gSetUpScrapPict
  544. # ML    11/15/95    added gScriptBeginCritical and gScriptEndCritical hooks
  545. #########################################################################
  546. TASK DoSetUpApp(pDismissOpeningDialog:=0, pDefaultWindowSpec:=0, pNewDocPath:={'New','File'},
  547. pDismissNewDocDialog:=0,pScrapText:=0, pScrapPict:=0, pSaveDoc:=1, pOpenDoc := 2)
  548. begin
  549.     If (global gDoSetUpAppHook1)
  550.         call (gDoSetUpAppHook1);
  551.     global gFileName,gApptitle;
  552.     LogStr("The expected application is '{gAppTitle}'.");
  553.     MatchApplication(0);
  554.  
  555.     if (pDismissOpeningDialog)
  556.     begin
  557.         if (global gCustomOpeningDialog)             # if custom Opening dialog
  558.             Specifier := gCustomOpeningDialog;        # define global for DismissDialog
  559.         else 
  560.             Specifier := [window o:1 s:dialog];
  561.         if (findWindow(Specifier, true))            # no opening dialog if twitched to
  562.         begin
  563.             LogStr('Dismissing opening dialog');
  564.             TCSStart({ 1, global kTCSetAppSetup },"Dismiss opening dialog");
  565.             TCSEnd({ 1, global kTCSetAppSetup },DismissDialog(pDismissOpeningDialog,Specifier));
  566.         end;
  567.     end;
  568.         
  569.     If (global gDoSetUpAppHook2)
  570.         call (gDoSetUpAppHook2);
  571.     
  572.     if (global gAdditionalTargetInfo)
  573.             ProfileApplication();
  574.                 
  575.     if (pDefaultWindowSpec >= 0 or TypeOf(pDefaultWindowSpec) = 'string' 
  576.     or TypeOf(pDefaultWindowSpec) = 'descriptor')
  577.     begin
  578.     
  579.         if _matchBoolean ([window o:1]!)
  580.         begin
  581.             if (FindWindow(pDefaultWindowSpec, true))
  582.                 CloseWindow(,,pDefaultWindowSpec);
  583.         end; 
  584.     end; 
  585.             
  586.     if (pNewDocPath)
  587.     begin
  588.         TCSStart({ 1, global kTCSetNewDoc },"Select File - New...");
  589.         if(Card(pNewDocPath) = 2)
  590.             TCSEnd({ 1, global kTCSetNewDoc },SelectMenuItem(pNewDocPath[1], pNewDocPath[2]));    # Open a New Document
  591.         else if(Card(pNewDocPath) = 3)
  592.             TCSEnd({ 1, global kTCSetNewDoc },SelectMenuItem(pNewDocPath[1], pNewDocPath[2], pNewDocPath[3]));    # Open a New Document
  593.     end;
  594.     
  595.     if (pDismissNewDocDialog)
  596.     begin
  597.         if (global gCustomNewDocDialog)                 # if custom Opening dialog
  598.             Specifier := gCustomNewDocDialog;            # define global for DismissDialog
  599.         else 
  600.             Specifier := [window o:1 s:dialog];
  601.         if (findWindow(Specifier, true))                # no opening dialog if twitched to
  602.         begin
  603.             logstr('Dismissing new document dialog');
  604.             TCSStart({ 2, global kTCSetAppSetup },"Dismiss new document dialog");
  605.             TCSEnd({ 2, global kTCSetAppSetup }, DismissDialog(pDismissNewDocDialog, Specifier));
  606.         end;
  607.     end;
  608.     
  609.     if (pScrapText)
  610.     begin
  611.         if global gScriptBeginCriticalHook                # hook for threading
  612.             call (gScriptBeginCriticalHook);
  613.         if global gCustomScrapText                        # hook for custom scrap text
  614.             call (gCustomScrapText);
  615.         else
  616.         begin
  617.             Scrapbook(global kScrapTEXT);                # Paste TEXT from Scrapbook
  618.             #SpecialKey(returnKey , "Return Key");
  619.         end;
  620.         if global gScriptEndCriticalHook                # hook for threading
  621.             call (gScriptEndCriticalHook);
  622.     end; # if (pScrapText)
  623.     
  624.     if (pScrapPict)
  625.     begin
  626.         if global gScriptBeginCriticalHook                # hook for threading
  627.             call (gScriptBeginCriticalHook);
  628.         if global gCustomScrapPict                        # hook for custom scrap pict
  629.             call (gCustomScrapPict);
  630.         else
  631.             Scrapbook(global kscrapPict);
  632.         if global gScriptEndCriticalHook                # hook for threading
  633.             call (gScriptEndCriticalHook);
  634.     end; # if (pScrapPict)
  635.         
  636.     if (global gSetUpForSaveDoc)                        # hook to setup for Saving Document
  637.         call (gSetUpForSaveDoc);
  638.         
  639.     if (pSaveDoc)
  640.         DoFiles(2,gFileName, pSaveDoc, pOpenDoc);
  641.  
  642. end; # DoSetUpApp()
  643.  
  644. #########################################################################
  645. #     DoCloseApp(pSaveRevert, pDismissAboutBox, pPageSetup, pPrinter, pQuit)
  646. #=======================================================================
  647. # Author:              ML
  648. # Description:        Performs either DoFiles(3) or Dofiles(5), Selects and dismisses
  649. #                    the 'About' box, Selects and dismisses 'Page Setup', Selects and
  650. #                    dismisses 'Print', thenpQuits.
  651. # Parameters:        pSaveRevert -    0 - Save As/Cancel/Save, no modify/revert
  652. #                                    1 - Save As/Cancel/Save, modify/revert
  653. #                                   -1 - no Save As/Cancel/Save, no modify/revert
  654. #                                    {list} - International - two elements 
  655. #                                        1st element 
  656. #                                            list - list containing ordinality of 'Revert' menuItem.
  657. #                                            integer - Any of the pSaveRevert options listed above.
  658. #                                        2nd Element - should be set even if 1st element is 0
  659. #                                            list - list containing ordinality of 'Save As' menuItem.
  660. #                    pDismissAboutBox -  -1 - Don't do About Box test
  661. #                                        0 - Return key
  662. #                                        integer > 0     - Click in center of 
  663. #                                                        screen {integer} times
  664. #                                        String -  Select button named <string>
  665. #                    pPageSetup -            
  666. #                                        0 - Don't do default PageSetup()
  667. #                                        1 - Do default PageSetup()
  668. #                                        list - list containing ordinality of 'Page Setup' menuItem.
  669. #                    pPrinter -             
  670. #                                        0 - Don't do default Printer()
  671. #                                        1 - Do default Printer()
  672. #                                        list - list containing ordinality of 'Print' menuItem. 
  673. #                    pQuit -                
  674. #                                        0 - Don't call Quit() Task 
  675. #                                        1 - Select 'Quit' - hard coded
  676. #                                        2 - KeyEq('q');
  677. #                                    {list}- ord or string path to Quit menuitem, i.e.
  678. #                                                {"Quit", "File"} or {17, 2}
  679. # Returns:            None
  680. #
  681. # Example:            DoCloseApp(1,2)
  682. #=======================================================================
  683. # History:
  684. # KTA    7/14/93 International support: can pass in pSaveRevert as a list of 
  685. #                menuitems for saveAs and Revert. Also for pPageSetup, and pPrinter
  686. # KTA    9/10/93 AboutBox was not being called if pDismissAboutBox was a string
  687. # KTA    12/1/93 Generic output line "About Box is not being tested" (bug 1121688)
  688. # KTA    12/1/93 Deleted call to DoSpecialTest() and added hooks gDoCloseAppHook1, 
  689. #                gDoCloseAppHook2, gDoCloseAppHook3
  690. # ML    11/15/95    added gScriptBeginCritical and gScriptEndCritical hooks
  691. #########################################################################
  692. TASK DoCloseApp(pSaveRevert := 0, pDismissAboutBox := 0, pPageSetup := 1,
  693.                     pPrinter := 1, pQuit := 1)
  694. begin
  695.     global gFileName, gApptitle;
  696.     RevertMI := '';
  697.     SaveAsMenu := 1;
  698.  
  699.     If (global gDoCloseAppHook1)
  700.         call (gDoCloseAppHook1);
  701.  
  702.     if(TypeOf(pSaveRevert) = 'list')
  703.     begin
  704.         SaveAsMenu := pSaveRevert[2];
  705.         if(TypeOf(pSaveRevert[1]) = 'list')
  706.         begin
  707.             RevertMI := pSaveRevert[1];     # Set RevertMI to the menuItem was passed in. 
  708.             pSaveRevert:= 1;             # if a menuItem was passed in Revert must be true
  709.         end;
  710.         else
  711.             pSaveRevert := pSaveRevert[1];
  712.     end;
  713.     
  714.     if (pSaveRevert > 0)                    # if app supports revert
  715.         DoFiles(3,,SaveAsMenu,,RevertMI);        # save as/Cancel, save, modify, revert
  716.     else if (pSaveRevert = 0)                    # else if 0, no revert
  717.     begin
  718.         logstr("There is no revert in '{gApptitle}'");
  719.         DoFiles(5,,SaveAsMenu);                    # save as/Cancel, save
  720.     end;                                        # if pSaveRevert < 0, do nothing
  721.     
  722.     if not(pDismissAboutBox = -1)                        # test about box
  723.     begin
  724.         if global gScriptBeginCriticalHook                # hook for threading
  725.             call (gScriptBeginCriticalHook);
  726.         AboutBox(pDismissAboutBox);
  727.         if global gScriptEndCriticalHook                # hook for threading
  728.             call (gScriptEndCriticalHook);
  729.     end;
  730.     else
  731.         logstr("About Box is not being tested");
  732.     
  733.     if (TypeOf(pPageSetup) = 'list')        # Support for (intl)
  734.         PageSetup(, pPageSetup);                            # Page Setup Testing
  735.     else if (pPageSetup)
  736.         PageSetup();                            # Page Setup Testing
  737.     
  738.     if (TypeOf(pPrinter) = 'list')        # Support for (intl)
  739.         Printer(pPrinter);                                # Print Testing
  740.     else if (pPrinter)
  741.         Printer();                                # Print Testing
  742.     
  743.     
  744.     If (global gDoCloseAppHook2)
  745.         call (gDoCloseAppHook2);
  746.     
  747.     if not (pSaveRevert < 0)                        # if haven't done any save above
  748.         SaveAs(gFileName,0,SaveAsMenu);                    # Save as, new file
  749.     
  750.     if (pQuit)
  751.     begin
  752.         if global gScriptBeginCriticalHook                # hook for threading
  753.             call (gScriptBeginCriticalHook);
  754.         Quit(,,pQuit);                            # Quit
  755.         if global gScriptEndCriticalHook                # hook for threading
  756.             call (gScriptEndCriticalHook);
  757.     end;
  758.     
  759.     If (global gDoCloseAppHook3)
  760.         call (gDoCloseAppHook3);
  761. end;